Skip to content

feat: expose effective cache-mode to steps via ACTIONS_CACHE_MODE#4538

Merged
philip-gai merged 5 commits into
mainfrom
philip-gai/cache-mode-env
Jul 9, 2026
Merged

feat: expose effective cache-mode to steps via ACTIONS_CACHE_MODE#4538
philip-gai merged 5 commits into
mainfrom
philip-gai/cache-mode-env

Conversation

@philip-gai

@philip-gai philip-gai commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Exposes the effective Actions cache-mode to job steps and surfaces it in the job log. The mode is delivered by the Actions service as the actions_cache_mode job variable (one of none, read, write, write-only, hyphenated), mirroring the existing actions_uses_cache_service_v2 variable.

Changes

  • Export env ACTIONS_CACHE_MODE to steps from the actions_cache_mode job variable in NodeScriptActionHandler and ContainerActionHandler, mirroring the existing ACTIONS_CACHE_SERVICE_V2 wiring.
  • Log the effective cache-mode at job start in JobExtension (single info line near the other job header output).

Behavior and safety

  • The value is provided by the Actions service as the actions_cache_mode job variable, one of none|read|write|write-only (hyphenated, matching the workflow YAML token). The runner passes it through as-is.
  • The runner only reacts when the variable is present and non-empty. With no cache-mode set, behavior is identical to today (no new env var, no new log line).
  • Emission of the variable is gated on the service side, so no separate runner feature flag is required.

Tests

  • L0 handler coverage for read, none, write, and write-only (env exported with the value), plus absent and empty cases (env not set).

https://github.com/github/actions-persistence/issues/1125

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes the effective Actions cache mode (from the service-provided actions_cache_mode job variable) to action steps via ACTIONS_CACHE_MODE, and logs the cache mode once at job start to make the effective mode visible in the job header output.

Changes:

  • Export ACTIONS_CACHE_MODE from actions_cache_mode in NodeScriptActionHandler and ContainerActionHandler.
  • Log Actions cache-mode: <mode> during job initialization in JobExtension when the variable is present and non-empty.
  • Add/extend L0 tests to validate log emission and env export behavior (notably for NodeScriptActionHandler and JobExtension).
Show a summary per file
File Description
src/Test/L0/Worker/JobExtensionL0.cs Adds L0 coverage asserting the new job-start log line when actions_cache_mode is set/absent.
src/Test/L0/Worker/HandlerL0.cs Adds L0 coverage asserting ACTIONS_CACHE_MODE is exported by NodeScriptActionHandler for various modes and absent/empty cases.
src/Runner.Worker/JobExtension.cs Logs the effective cache mode at job start when present.
src/Runner.Worker/Handlers/NodeScriptActionHandler.cs Exports ACTIONS_CACHE_MODE for Node-based actions when actions_cache_mode is present and non-empty.
src/Runner.Worker/Handlers/ContainerActionHandler.cs Exports ACTIONS_CACHE_MODE into container action environments when actions_cache_mode is present and non-empty.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread src/Test/L0/Worker/JobExtensionL0.cs Outdated
Comment thread src/Runner.Worker/Handlers/ContainerActionHandler.cs
@philip-gai philip-gai marked this pull request as ready for review July 6, 2026 14:24
@philip-gai philip-gai requested a review from a team as a code owner July 6, 2026 14:24
Export ACTIONS_CACHE_MODE env to node and container action steps when the
actions_cache_mode job variable is present and non-empty, mirroring the
existing ACTIONS_CACHE_SERVICE_V2 wiring. Also log the effective cache-mode
at job start. When the variable is absent or empty, behavior is unchanged.
Add JobExtension L0 tests asserting the job-start cache-mode log line is
emitted for each mode and absent when the variable is unset, plus handler
regression tests covering coexistence with ACTIONS_CACHE_SERVICE_V2 and that
baseline runtime env is unaffected when no cache-mode is set.
- Add ContainerActionHandler L0 coverage (Linux-gated) asserting ACTIONS_CACHE_MODE
  is exported to the container env when actions_cache_mode is set and absent
  otherwise, routed through the container-hooks path.
- Set the cache-mode variable directly on the initialized job context instead of
  re-invoking InitializeJob, avoiding a redundant CancellationTokenSource.
@philip-gai philip-gai force-pushed the philip-gai/cache-mode-env branch from bb2d05a to b91b39e Compare July 9, 2026 17:11
@philip-gai philip-gai enabled auto-merge (squash) July 9, 2026 17:11
@philip-gai philip-gai merged commit 6b19888 into main Jul 9, 2026
12 checks passed
@philip-gai philip-gai deleted the philip-gai/cache-mode-env branch July 9, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants